package com.matrix.java.chap_04;

import java.util.Scanner;

/*
    几何：最大圆距离
 */
public class Ex4_02 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter point 1 (latitude and longitude) in degrees: ");
        double x1 = input.nextDouble();
        double y1 = input.nextDouble();
        System.out.print("Enter point 2 (latitude and longitude) in degrees: ");
        double x2 = input.nextDouble();
        double y2 = input.nextDouble();
        double d = 6371.01 * Math.acos(Math.sin(Math.PI * x1 / 180) * Math.sin(Math.PI * x2 / 180)
                + Math.cos(Math.PI * x1 / 180) * Math.cos(Math.PI * x2 / 180) * Math.cos(Math.PI * (y1 - y2) / 180));
        System.out.println("The distance between the two points is " + d);
        input.close();
    }
}
